package com.ssm.Dao;

import com.ssm.Utils.DBCPUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class shopListDao {

    public List<Object> shop(String name){

        String sql="select * from v_all where name=?";
        Object[] objects={name};

        Object[] ob1=null;
        ResultSet resultSet = DBCPUtils.executeQuery(sql, objects);
        List<Object> objectList=new ArrayList<>();

        try {
            while (resultSet.next()){
                String c_pic=resultSet.getString("c_picture");
                int c_number=resultSet.getInt("c_number");
                String c_name=resultSet.getString("c_name");
                String c_type=resultSet.getString("c_type");
                int c_count=resultSet.getInt("c_count");
                int c_place=resultSet.getInt("c_place");

                ob1=new Object[]{c_pic,c_number,c_name,c_type,c_count,c_place};
                objectList.add(ob1);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            //关闭数据库的方法
            DBCPUtils.closeAll(resultSet, DBCPUtils.pstmt, DBCPUtils.connection);
        }
//        for(Object object1:objectList){
//            Object[] o= (Object[]) object1;
//            for(Object object2:o){
//                System.out.println(object2.toString());
//            }
//        }
        return objectList;
    }

}
